package 动态规划;

/**
 * @ClassName _70爬楼梯
 * @Description TODO
 * @Author 昝亚杰
 * @Date 2021/12/29 20:17
 * Version 1.0
 **/
public class _70爬楼梯 {
    public static int climbStairs(int n) {//同斐波那契数列
        if(n <= 2) return n;
        int a = 1, b = 2, sum = 0;

        for(int i = 3; i <= n; i++){
            sum = a + b;
            a = b;
            b = sum;
        }
        return b;
    }
    public static int fib(int n) {
        int[] res = new int[n + 1];
        res[0] = 0;
        res[1] = 1;
        if(n < 2){

        }
        for(int i = 2; i <= n; i++){
            res[i] = res[i - 1] + res[i - 2];
        }
        return res[n];
    }

    public static void main(String[] args) {
        int fib = fib(0);
        System.out.println(fib);
    }
}
